<% this.title = '作业' %>
<% include header %>
<div class="padding">
    <% if (homeworks.length) { %>
    <% if (user && allowManage) { %>
    <form class="ui mini form">
      <div class="inline fields" style="margin-bottom: 25px; white-space: nowrap; ">
        <a href="<%= syzoj.utils.makeUrl(['homework', 0, 'edit']) %>" class="ui mini labeled icon right floated button" style="margin-left: auto; ">
          <i class="ui icon write"></i>
          新建作业
        </a>
     </div>
    </form>
    <% } %>
    <table class="ui very basic center aligned table">
      <thead>
        <tr>
          <th><span style="float:left; margin-left: 20px;">作业名称</span></th>
          <th style="text-align: left; width: 70%;">描述</th>
        </tr>
      </thead>
      <tbody>
        <% for (let homework of homeworks) { %>
        <tr>
          <td><a style="float:left; margin-left: 20px;" href="<%= syzoj.utils.makeUrl(['homework', homework.id]) %>"><%= homework.title %> <% if (!homework.is_public) { %><span class="ui header"><div class="ui tiny red label">未布置</div></span><% } %></a></td>
          <td class="font-content" style="text-align: left;"><%- homework.subtitle %></td>
        </tr>
        <% } %>
      </tbody>
    </table>
    <% } else { %>
    <div class="ui placeholder segment">
      <div class="ui icon header">
        <i class="calendar icon" style="margin-bottom: 20px; "></i>
        暂无作业
      </div>
      <% if (user && allowManage) { %>
      <a href="<%= syzoj.utils.makeUrl(['homework', 0, 'edit']) %>" class="ui primary labeled icon button">
        <i class="ui icon write"></i>
        布置第一份作业
      </a>
      <% } %>
    </div>
    <% } %>
  <br>
  <% include page %>
</div>
<% include footer %>
